﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsLiveWriter.TagGenerator
{
	public partial class TagForm : Form
	{
		private IEnumerable<string> tags;
		public IEnumerable<string> Tags
		{
			get
			{
				return tags;
			}
		}

		public TagForm(string content)
		{
			InitializeComponent();

			if ((content != null) && (content != string.Empty))
			{
				TagGenerator g = new TagGenerator();

				foreach (var tag in g.GetTags(content))
					tagListBox.Items.Add(tag);
			}
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
			base.Close();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.tags = getSelectedTags();

			base.DialogResult = DialogResult.OK;
			base.Close();
		}

		private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
		{
			tagListBox.Items.Remove(tagListBox.SelectedItem);
		}

		private IEnumerable<string> getSelectedTags()
		{
			foreach (var i in tagListBox.Items)
				yield return (string)i;
		}
	}
}